package com.taobao.ui.menu;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;

import com.taobao.action.CommonAction;

public class CommonMenu extends Menu implements SelectionListener {

	private Map<MenuItem, CommonAction> map = new HashMap<MenuItem, CommonAction>();

	private String currentCellWord;
	
	public CommonMenu(Control parent) {
		super(parent);
	}

	@Override
	public void widgetDefaultSelected(SelectionEvent e) {
	}

	@Override
	public void widgetSelected(SelectionEvent e) {
		MenuItem menuItem = (MenuItem) e.getSource();
		CommonAction commonAction = map.get(menuItem);
		commonAction.doAction(this);
	}

	public void bindingAction(MenuItem menuItem, CommonAction commonAction) {
		map.put(menuItem, commonAction);
	}

	@Override
	protected void checkSubclass() {
	}

	public String getCurrentCellWord() {
		return currentCellWord;
	}

	public void setCurrentCellWord(String currentCellWord) {
		this.currentCellWord = currentCellWord;
	}
}
